using System;

namespace StubsDemo.SystemUnderTest.ViewModels
{
	public class CustomerViewModel : ViewModelBase
	{
		private Customer customer;
		private readonly ICustomerRepository repository;

	    public CustomerViewModel()
	    {
            customer = new Customer();
	    }

		public CustomerViewModel(Customer customer, ICustomerRepository repository)
		{
			this.customer = customer;
			this.repository = repository;
		}

	    public string CustomerName
		{
			get { return customer.Name; }
			set
			{
				customer.Name = value;
				RaisePropertyChanged("CustomerName");
			}
		}

		public void Save()
		{
			customer = repository.SaveOrUpdate(customer);
		}
	}
}